package com.cq.base.recycleview.drag

import androidx.recyclerview.widget.DiffUtil


/**
 * 作者: CQ
 * 日期: 2021-07-13
 * 说明:
 */
abstract class DiffUtilAdapter<T> : DiffUtilAdapterCallBack<T>() {



    public fun add(itemList: MutableList<T>){
        val diffUtil = DiffUtil.calculateDiff(this)

    }

}

abstract class DiffUtilAdapterCallBack<T> : DiffUtil.Callback() {
    private var listOld: MutableList<T>? = null
    private var listNew: MutableList<T>? = null

   fun add(listOld: MutableList<T>, listNew: MutableList<T>) {
        this.listOld = listOld
        this.listNew = listNew
    }

    override fun getOldListSize(): Int {
        return listOld!!.size
    }

    override fun getNewListSize(): Int {
        return listNew!!.size
    }

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        return areItems(oldItemPosition, newItemPosition)
    }

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        return areContents(oldItemPosition, newItemPosition)
    }

    abstract fun areItems(oldItemPosition: Int, newItemPosition: Int): Boolean
    abstract fun areContents(oldItemPosition: Int, newItemPosition: Int): Boolean
}